Repository navigation
perf(console): plugin-form and plugin-view helpers come from side-effect-free /core subpaths - #34176
Conversation
…ect-free /core subpaths The console shell imports the pure helpers from @object-ui/plugin-form/core and @object-ui/plugin-view/core, draws ModalForm and the flow screen's ObjectForm behind lazy(), and registers the two packages' tags as lazy stubs, so neither entry is part of the first load. Claude-Session: https://claude.ai/code/session_01ADHkmT5bCDp1MDcReXVCop Co-authored-by: Claude <noreply@anthropic.com>
…ubpaths Claude-Session: https://claude.ai/code/session_01ADHkmT5bCDp1MDcReXVCop Co-authored-by: Claude <noreply@anthropic.com>
…e read them through the old eager graph The console registers the form tags as lazy stubs now, and the shell draws its forms through lazy(); suites that read a form block's inputs or rendered a form synchronously load the package themselves or wait for it. Claude-Session: https://claude.ai/code/session_01ADHkmT5bCDp1MDcReXVCop Co-authored-by: Claude <noreply@anthropic.com>
…rm and view in the console Claude-Session: https://claude.ai/code/session_01ADHkmT5bCDp1MDcReXVCop Co-authored-by: Claude <noreply@anthropic.com>
… array An entry form is always named, so a bundler keeps the subpath's module; the derived enumeration finds no registering module behind it. Claude-Session: https://claude.ai/code/session_01ADHkmT5bCDp1MDcReXVCop Co-authored-by: Claude <noreply@anthropic.com>
…t judged for a load-time effect check-side-effects-array and this file's coverage direction both require every entry form in the array; a side-effect-free exports subpath is named for that reason, not as a claim that it registers. The barrel is still judged. Claude-Session: https://claude.ai/code/session_01ADHkmT5bCDp1MDcReXVCop Co-authored-by: Claude <noreply@anthropic.com>
…core subpaths Claude-Session: https://claude.ai/code/session_01ADHkmT5bCDp1MDcReXVCop Co-authored-by: Claude <noreply@anthropic.com>
|
domain:ui#1 · os-steve · session_01ADHkmT2NE3iyG1o6TDg3sf Contract reviewServed-tier: Face: declaration. ① Derived judgments
② Semver level
③ Boundary flags
Implemented-by: VERDICT: PASS |
|
domain:ui#1 · os-steve · session_01ADHkmT2NE3iyG1o6TDg3sf 席位核对Verdict: ACCEPT · head
|
…ackages (objectstack-ai#36336) <!-- claude-projects-attribution: {"github_login":"os-project-manager"} --> _Requested by **Leehom** · [project thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1X1qGnTYLQs3EtmtCmjrcfCe)_ Fixes objectstack-ai#33581 Clause-②: yes (widening) — one new published `exports` subpath, `@object-ui/plugin-detail/core`; nothing removed or renamed, the package root exports the same names as before Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:控制台第一次打开任何页面时少下载约 165 KB(压缩后,约为首屏下载量的 8%);首页、仪表盘、列表页、记录页、记录浮层画面和操作都不变。 - 为什么做:控制台首屏提速——过去每个页面都要先下载表格和详情组件,再去读数据。 - 出错会怎样:若某处漏改,表格或详情块第一次出现时会多等一次加载,画面内容不变;本改动可以直接撤回。 - 要你做什么:无。 ## What changes On every route the console used to download the `plugin-grid` chunk (all of `@object-ui/plugin-grid` plus 77 `@object-ui/plugin-detail` modules, 183 KB gzip) before its first data read. That chunk now leaves the eager closure; the list and record routes fetch it with their own route chunks, and any other surface fetches it the first time it draws a grid or a detail block. - **`@object-ui/plugin-detail/core`** (new subpath, ESM only, like the other `/core` subpaths): the pure helpers the console shell needs on every page, registering nothing. Names: `isRefusedFeedRead`, `relatedListEntryNames`, `RELATED_ARRANGEMENT_RECORD_VERSION`, `relatedArrangementFromRecord`, `relatedArrangementToRecord`, `deriveFieldGroupDetailSections`, `deriveHighlightFields`, `resolveDetailSections`, `isWideFieldType`, `prefetchRelatedCounts`, `relatedCountTargetsIn`, `COMPACT_RELATED_ROWS`, `normalizeRelatedListSort`, `seedQueueClaimDecision`, `seedRecordFieldAccess`, `seedRecordVerdict`, type `RelatedArrangement`. The root still exports all of them. `normalizeSortSpec` moved verbatim from `RelatedList.tsx` to `relatedListSort.ts` so the subpath does not reach the component. - **Published ESM build of plugin-detail**: a second pass (`vite.es.config.ts`) emits `index` and `core` in one pass with `preserveModules`, so the record-page caches the `/core` seeds write are the same module instances the root's hooks read. File names match the package's existing `sideEffects` spellings (`./dist/queueClaim.js` and friends). The UMD build is unchanged. - **Console shell** (`@object-ui/app-shell`): eight modules take the helpers from `/core`. The record pointer card's key fields and the approval decision's child tables draw `HeaderHighlight` / `RelatedList` through `lazy()` wrappers (`lazyDetailSurfaces.tsx`); the pointer card starts the chunk load beside its record read (no timeout raised). A wrapper mounted after the chunk loaded draws without suspending. - **Console** (`register-plugins.ts`): the bare `import '@object-ui/plugin-grid'` / `import '@object-ui/plugin-detail'` become `registerLazy` stubs for every tag the two packages register, with the namespaces their registrations declare: `object-grid`, `view:grid`, `detail-view`, `detail-section`, `view:detail`, and the eleven `record:` blocks (`details`, `related_list`, `highlights`, `activity`, `chatter`, `discussion`, `path`, `quick_actions`, `history`, `reference_rail`, `alert`). `App.tsx` loads the dev-only row-actions page lazily. `vite.config.ts` gets a `plugin-detail-core` chunk group so the subpath's closure does not fall into the `plugin-grid` group. The card's other two slices were already in place on main: `plugin-form` and `plugin-view` were lazy behind their `/core` subpaths (objectstack-ai#34176), and `RecordDetailView` / `ObjectView` sat behind the lazy route boundary (objectstack-ai#33677). Step 1 below shows it. ### Step 1: main `29556850`, what held each package eager Eager closure 2,042,500 B gzip, 105 of 2551 chunks. Largest eager chunks: `vendor-objectstack` 673,811 · `ui-components` 351,125 · **`plugin-grid` 183,395** · `index` 135,521 · `framework` 88,559 · `vendor-react` 81,619 · `i18n-locale-en` 66,610 · `vendor-radix` 59,724 · `src` 43,005 · `infrastructure` 37,749. | Package | Eager on main? | Edges holding it | |---|---|---| | plugin-grid (chunk = 74 grid + 77 detail modules) | yes, 183,395 B | `register-plugins.ts` bare imports of grid and detail; `App.tsx` to `dev/DevRowActions.tsx` (ObjectGrid); app-shell named imports from the plugin-detail root in `sharedUserFeeds`, `deriveRelatedLists`, `workspacePreference`, `recordDetailSections`, `recordDrawerStack`, `recordPagePayload`, `SubmittedRecord` (RelatedList), `RecordPreviewCard` (HeaderHighlight) | | plugin-form | no (only `plugin-form-core`, 6,652 B) | none; lazy since objectstack-ai#34176 | | plugin-view | no (only `plugin-view-core`, 1,789 B) | none; lazy since objectstack-ai#34176 | | RecordDetailView | no | none; behind the lazy route boundary since objectstack-ai#33677 | ### Before / after | Build | Eager gzip bytes | Eager chunks | grid / form / detail / RecordDetailView eager | |---|---|---|---| | main `337f435c` | 2,043,450 | 105 | `plugin-grid` 183,666 | | this branch `feb24f53` (same base) | 1,874,495 (**−168,955**) | 105 | none; `plugin-detail-core` 15,702 joins | | this branch head `58e12ffd` (main `99fbaa6d` merged) | 1,875,181 | 105 | none (`plugin-detail-core` 15,702, `plugin-form-core` 6,654, `plugin-view-core` 1,789) | The head row includes main's own drift between the two merges (for example `ui-components` +662 B). `check:eager-closure` on head: exit 0, 1831.2 KB, headroom 600.4 KB. Lazy chunks, gzip (python gzip -6, main `337f435c` vs head `feb24f53`): `plugin-grid` 183,368 / 188,399 · `plugins-views` 62,376 / 55,420 · `plugin-form` 47,198 / 47,212 · `plugin-view` 19,846 / 19,846 · `RecordDetailView` 29,554 / 30,003. The grid chunk grows by the detail renderers that left `plugins-views`. ## Tests Local, scoped (CI runs the full suites): - Before the last main merge, head `feb24f53`: 406 test files (app-shell tests of every touched module, all console `__tests__`, plugin-detail, the `ui/scripts` side-effects and declared-lazy-views tests): 405 passed, 1 failed (`RecordPreviewCard.test.tsx`, the highlight strip under the new lazy wrapper). Fixed in `feb24f53`; that file plus the pins rerun: 13 files / 149 tests passed. - `type-check` for `@object-ui/plugin-detail`, `@object-ui/app-shell`, `@object-ui/console`: exit 0 (on `feb24f53` and again on `58e12ffd`). eslint on the changed files: exit 0. `vitest` over `scripts/`: 5127 tests passed. - Head `58e12ffd` (after merging main `99fbaa6d`): full turbo build exit 0, eager-closure budget exit 0, type-checks exit 0. The scoped test rerun on this head (493 files) was still running when this body was written (handover cut-off): **NOT MEASURED on `58e12ffd`**, CI is the reading. Pins: `ui/packages/app-shell/src/__tests__/pluginCoreSubpaths-33581.test.ts` now also holds `plugin-detail/core` (names, no registrations) and the eager modules (App, register-plugins, the eight shell modules, `lazyDetailSurfaces`) to subpath-or-type-only imports of plugin-detail and plugin-grid. Ablations (one-shot, on committed head `feb24f53`, each restored with `git checkout HEAD --`, blob hash compared, `git diff HEAD` empty): 1. `recordPagePayload.ts` back to the plugin-detail root import: all three pin tests red (offender listed, importer floor 8 of 9). 2. bare `import "@object-ui/plugin-grid"` added to `register-plugins.ts`: the bare-import pin red ("bare import from '@object-ui/plugin-grid'"). The first attempt at this ablation was a no-op (the replacement contained the anchor; the replace tool refused it); redone with a different quote spelling. ## Acceptance notes - Real browser (Chromium, showcase app, signed in as admin; the same server served the `337f435c` console build and then this branch's), five routes: home, a dashboard, an object list, a record page, a record overlay. All five drew on both builds with the same text, no page errors beyond a 404 the home page shows on both, no failed requests. - main fetched `plugin-grid` 40–75 ms after navigation on every route, before the first data read (667–1144 ms). - this branch: home and dashboard never fetch `plugin-grid`; the list fetches it at 1032 ms beside `ObjectView` (1050); the record page at 882 ms beside `RecordDetailView` (900); the overlay at 1027 ms. - JS requests per route (main / head): home 105 / 105, dashboard 143 / 140, list 227 / 201, record 171 / 156, overlay 229 / 203. - No carve-out naming `plugin-grid` is added to the eager-closure budget check, and none is owed. New gates are "no" by default unless the maintainer names one, and this class is already held by two things: the source pin `pluginCoreSubpaths-33581` (ablation 2 turns it red) and the total `check:eager-closure` budget. - `plugin-detail-core` (15,702 B gzip at this head) also holds `ConcurrentUpdateDialog`, because `isConcurrentUpdateError` is in the same module. That share of the chunk is not measured on its own. ## Verification Read first: 1. `ui/apps/console/src/register-plugins.ts` — a tag the two packages register but the stubs miss would draw an unresolved component on first use. 2. `ui/packages/plugin-detail/vite.es.config.ts` + `package.json` — the published ESM layout changes to one file per module; the seed caches depend on it. 3. `ui/packages/app-shell/src/views/lazyDetailSurfaces.tsx` — first-draw loading of the two shell detail components. Two-minute check: `pnpm --filter @object-ui/console build`, then `node -e 'const j=require("./ui/apps/console/dist/eager-closure.json");console.log(j.eagerGzipBytes, j.files.filter(f=>/^(plugin-|RecordDetailView|plugins-)/.test(f.name)).map(f=>f.name))'` from the repo root. Expected: about 1,875,000, and only `plugin-chatbot-core`, `plugin-detail-core`, `plugin-form-core`, `plugin-view-core`, with no `plugin-grid`. Gates: `node scripts/pm/dispatch-gates.mjs --commands` derived 60 families on `f3214b28`; all 60 ran locally and `--ran` reconciled 60 of 60, 0 NOT MEASURED, exit 0. First runs of four families read wrong and were rerun after a full build: dts-closure exit 1 (console `.d.ts` not built yet), dual-build-cjs-loads exit 3 (prerequisite unbuilt), query-options-erasure 124 (my own 300 s timeout), type-check-debt (I stopped its lock-held rebuild); all four reran to exit 0. UI extras: `check:side-effects-array` 0, `check:sdui-registration-pins` 0, `check:eager-closure` 0, `vite-declared-lazy-views` passed inside the builds (13 of 13 lazy). The gate set was not rerun on `58e12ffd` (a clean main merge); the PR check-runs are the reading there. Written by `repo:objectstack#4 · os-project-manager · session_01FEkQ5kt9AD1TPLy7Y9oa9D` (https://claude.ai/code/session_01FEkQ5kt9AD1TPLy7Y9oa9D). 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- signed: repo:objectstack#4 · os-project-manager · session_01FEkQ5kt9AD1TPLy7Y9oa9D --> --------- Co-authored-by: Claude <noreply@anthropic.com>
Requested by Steve · project thread
Part of #33581
Clause-②: yes (widening) — two new published
exportssubpaths,@object-ui/plugin-form/coreand@object-ui/plugin-view/core; nothing removed or renamed, the package roots export the same names as beforeMetadata-protocol: none
维护者速读
/core子路径,壳层只从它取辅助函数;表单和视图组件在第一次画出时才加载。/core包会在发布包里造出第二个实例,种子写不到根入口那一份;要改发布包的构建形状,需要席位定。plugin-grid 因此仍在首屏。What changes
Two side-effect-free subpaths.
@object-ui/plugin-formand@object-ui/plugin-viewregister their renderers when their root entry is evaluated, and each root reaches every surface of its package. One pure helper imported from a root kept the whole package in the console's first load. Each package now publishes/core(ESM only, built by a secondvite build --config vite.core.config.tspass, the@object-ui/plugin-chatbot/coreprecedent), and it registers nothing:plugin-form/core(src/core.ts):filterSystemFields,isAutoGeneratedFieldType,isWideFieldType,inferColumns,containerGridColsFor,resolveInlineMode,omitServerResolvedDefaults,optionListDefault,resolveSectionGroupReferences,useInitialFieldFocus, plus their parameter types.plugin-view/core(src/core.ts):deriveRecordSurface,deriveRecordFlowSurface,overlayWidthFor,toFilterGroup,deriveFieldOptions,isImageLikeField,isGeoLikeField,pickPreferredField, the three*_PREFERREDlists, plus their types.The roots still export every one of these names, unchanged. Both
sideEffectsarrays name the new entry form (./src/core.ts,./dist/core.js), ascheck:side-effects-arrayrequires of every entry; its derived walk finds no registering module behind either.The shell takes its helpers from
/core. Eleven importers moved:MetadataProvider,ActionParamDialog,ObjectFormDesigner,editFormLockedByState,SchemaForm, the console'sFormPage,AppContent,objectViewRecordNavigation,userFilterUrlState,recordDrawerStack,CreateViewDialog.Forms drawn outside a route load on first draw.
views/lazyFormSurfaces.tsxwrapsModalFormandObjectForminlazy()+Suspense.AppContent(the global record form),useActionModal(the action form) andScreenView(a flow's object-form screen) draw through it.The console registers the two packages' tags as lazy stubs.
register-plugins.tsdrops its eagerimport '@object-ui/plugin-form'/'@object-ui/plugin-view'and registersobject-form,embeddable-form,object-master-detail-form,view:form,record:line_items,object-view,view:simple,view-switcher,filter-ui,sort-uiwithregisterLazy, each with the namespace,skipFallbackand category its real registration declares.check:sdui-registration-pinsconfirms every promised registration is still in the built console.Bundling.
apps/console/vite.config.tsaddsplugin-form-coreandplugin-view-coregroups at priority 71 withincludeDependenciesRecursively: false, so the core modules do not land in (and drag in) the priority-70 package chunks.ui/vitest.config.mtsaliases both/coresubpaths to source, ahead of the bare package aliases.Why
Card #33581 item 1. Measured with #33677's method: a production build of the console,
dist/eager-closure.json, gzip of the closure and of the five watched chunks (nodezlib.gzipSync, the report's own level).86350e12plugin-gridplugin-formplugin-viewplugins-viewsRecordDetailViewplugin-form-core(new)plugin-view-core(new)check:eager-closurepasses on this head.Tests
app-shell/src/__tests__/pluginCoreSubpaths-33581.test.ts(3 tests). It reads the export names from the/coresubpaths themselves, scans every non-test source underapp-shell/srcandapps/console/src(floors: >500 files, ≥10/coreimporters), and fails when (a) any of them imports a/corename from a package entry, or (b) any of ten always-eager modules imports either entry by value, a bare import included.scripts/ablation-replace.mjs, restore proved by blob == HEAD and an emptygit diff HEAD):MetadataProvider.tsx:resolveInlineModefrom'@object-ui/plugin-form'→ (a) and (b) both red, naming the file and the name.register-plugins.ts:import '@object-ui/plugin-detail'→import '@object-ui/plugin-view'→ (b) red:bare import from '@object-ui/plugin-view'.apps/console/src/__tests__/masterDetailFormTypeManifest.test.ts,masterDetailFormI18nLabelManifest.test.ts,objectFormI18nLabelManifest.test.ts,registry-inputs-spec-parity.test.ts:import '@object-ui/plugin-form'beside../register-plugins, because a lazy stub carries noinputsand these read the manifest frominputs(the plugin-list precedent from PR 1).apps/console/src/__tests__/record-block-record-reach.test.tsx: the same import; it rendersrecord:line_itemssynchronously.apps/console/src/__tests__/public-contract.test.ts: the same import; the reverse direction readsrecord:line_items'sinputs.EXPECTED_LAZYis unchanged.app-shell/src/views/RecordDetailView.childWriteRefreshesParent-12244.test.tsx:import '@object-ui/plugin-grid'. The related list renders through the registeredobject-grid; this page reached it only through plugin-view's entry (ObjectViewimports plugin-grid). The console registers it inregister-plugins.ts.app-shell/src/views/__tests__/FlowRunner.suspense.test.tsx: the mockedObjectFormwas itself alazy(); ScreenView now takesObjectFormas the resolved value of its ownlazy(), and React refuses a lazy that resolves to a lazy. The mock is now a component that renders an inner lazy body (still suspending onformLoaded), and the mocked package is loaded once beforeFlowRunnerso its cold load does not eatwaitFor's budget.app-shell/src/views/metadata-admin/previews/ScreenPreview.test.tsx: the two object-form testsawait screen.findByTestId('object-form')instead of a synchronousgetByTestId.ui/scripts/__tests__/side-effects-declaration-consistency.test.ts: its phantom direction ("every declared source entry has a load-time side effect") contradictedcheck-side-effects-array.mjsand its own coverage direction, which both require every entry form in the array. A side-effect-free secondary entry (src/core.ts) could satisfy one only by failing the other. The phantom direction now skips secondary entry forms (exports subpaths other than the barrel) and still judges every barrel; a new anti-vacuity line pins that the exemption reaches the twosrc/core.tsand nosrc/index.*. Red before the edit (first gate run), green after.ui/scripts/__tests__/check-side-effects-array.test.ts: the population pin "every package walks from exactly one root" now names the multi-entry population exactly: plugin-form and plugin-view, each['src/core.ts', 'src/index.tsx']. The gate walks both roots and finds the same single registrar as before.Acceptance notes
Part of.queueClaim.ts,recordFieldAccess.tsxanduseRecordEditable.tskeep module-level caches withsubscribeDataChangessubscriptions and sit in plugin-detail'ssideEffectsarray. The shell seeds those caches (seedQueueClaimDecision,seedRecordFieldAccess,seedRecordVerdict). A/corebuilt as a separatedist/core.jsbundle, as here and in plugin-chatbot, would carry a second copy of each cache in the published package, so a seed written through core would never reach the hooks the root entry reads. Routing them needs a different published build shape (ES multi-entry with shared chunks, plussideEffectsglobs), which is a package-shape choice for the seat. Item 2 would also need lazy stubs for plugin-grid's and plugin-detail's tags and a lazyDevRowActions(imported statically byApp.tsx); only then does plugin-grid (160 KB) leave the first load. The detail-core closure measured at about 20 modules and contains no plugin-grid module.ModalFormis not inplugin-form/core. The card listed it with the helpers, but its closure is most of the form package, so/corewould stop being small. The shell loads it from the entry throughlazy()instead (lazyFormSurfaces.tsx).patch, notminor.Metadata-protocol: nonemaps topatchunder AGENTS.md's Post-Task Checklist step 3, andcheck-changeset-no-majorrefusesminorwithnone./coreduplicates three warning-dedupe sets (reported,warnedHeadinglessCollapse,reportedCurrencyColumnScales) in the published package. The worst case is a dev warning printed once more. No state the UI reads is duplicated. In the console, Vite resolves both to one source module, so nothing is duplicated there.LazyObjectFormcarries its ownSuspense, so a form screen body's suspension stops inside the dialog even without FlowRunner's. The pin still proves the route-level fallback never shows.ui/scripts/__tests__/**(two forced edits above). The card's surface did not name the sideEffects gates' tests, and the two checks could not both pass on any/coresubpath of an array package. The alternative wassideEffects: truefor both packages (the plugin-chatbot shape), which gives up tree-shaking for every consumer of the two packages; I chose the narrow reconciliation. The seat can ask for the other.apps/console/vite.config.ts(chunk groups),ui/vitest.config.mts(aliases). Untouched per the claim's serial limits: plugin-viewObjectView.tsx, plugin-gridObjectGridandsrc/index.tsx.Verification
type-check, includingtsconfig.test.json) all exit 0.pnpm --dir ui check:eager-closure,check:side-effects-array,check:sdui-registration-pins,check:new-line-citationsexit 0.eslinton the changed files: 0 errors.dispatch-gates.mjs --commands(59 commands) run and reconciled with--ran:59 derived famil(ies) accounted for — 58 run, 1 NOT-MEASURED. The NOT-MEASURED one ischeck:dual-build-cjs-loads(exit 3, prerequisite: unbuilt server packages; left to CI).pnpm --dir ui exec vitest run scripts/(the two sideEffects tests above; rerun 171 files passed),check:dts-closure(the console'splugin.d.tswas absent because the measurement build ranvite buildonly; afterbuild:plugin, 228/228 present).🤖 Generated with Claude Code
https://claude.ai/code/session_01ADHkmT5bCDp1MDcReXVCop